package com.epam.railway.jdbc.transform;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.epam.railway.jdbc.model.Passenger;


public class PassengerTransformer {
	
	public static List<Passenger> fromResultPassengerToList(ResultSet rs) {
		List<Passenger> list = new ArrayList<Passenger>();
		Passenger passenger;
		try {
			while(rs.next()) {
				passenger = new Passenger();
				passenger.setName(rs.getString("name"));
				passenger.setSurname(rs.getString("surname"));
				passenger.setEmail(rs.getString("email"));
				passenger.setRole(rs.getInt("role"));
				passenger.setPassword(rs.getString("password"));
				passenger.setStatus(rs.getInt("status"));
				list.add(passenger);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			passenger = null;
		}
		return list;

	}

}
